home *** CD-ROM | disk | FTP | other *** search
/ Info-Mac 3 / Info_Mac_1994-01.iso / Applications / ARTAbrot 1.0 / ComUtil_ARTAbrot.h < prev    next >
Text File  |  1993-08-23  |  10KB  |  225 lines

  1. /*   PComUtil_ARTAbrot_prj                Common and Utilitys
  2.  
  3. Name:  PComUtil_ARTAbrot_prj.h  
  4. Function:  Common for the Marksman™ specific code.
  5. History: 8/18/93 Original by George Warner
  6.    */
  7.  
  8. #include <SANE.h> /* Math definitions */
  9. #include <Values.h> /* Math type sizes */
  10. #include <Types.h> /* Basic Macintosh type definitions */
  11. #include <Memory.h> /* Memory structure types */
  12. #include <Resources.h> /* Resource file routines */
  13. #include <Quickdraw.h> /* QuickDraw types and routines */
  14. #include <Fonts.h> /* Font types and routines */
  15. #include <Events.h> /* Event types and routines */
  16. #include <Controls.h> /* Control routines */
  17. #include <Windows.h> /* Windows */
  18. #include <Menus.h> /* Menus */
  19. #include <TextEdit.h> /* Edit text */
  20. #include <Dialogs.h> /* Dialogs */
  21. #include <Desk.h> /* Desktop routines */
  22. #include <ToolUtils.h> /* Toolbox utilitys */
  23. #include <SegLoad.h> /* Init files selected */
  24. #include <OSUtils.h> /* OS utilitys */
  25. #include <Files.h> /* File routines */
  26. #include <OSEvents.h> /* OS events */
  27. #include <DiskInit.h> /* Floppy disk routines */
  28. #include <Packages.h> /* Extra packages */
  29. #include <CursorCtl.h> /* Cursor control */
  30. #include <Lists.h> /* List manager */
  31. #include <GestaltEqu.h> /* Gestalt definitions */
  32. #include <QuickDraw.h>  /* Color QD routines */
  33. #include <QDOffscreen.h> /* Color GWorld routines */
  34. #include <Sound.h> /* Sound manager */
  35. #include <Printing.h> /* Print manager */
  36.  
  37. /* ======================================================= */
  38.  
  39.  
  40. /* Basic definitions */
  41. #define TRUE        1                                /* Boolean true */ 
  42. #define FALSE        0                                /* Boolean false */ 
  43.  
  44. #define NIL        0L                                /* Used for empty pointers and handles */ 
  45.  
  46. /* User event definitions */
  47. #define UserEvent_None     0                        /* No user events available */
  48. #define UserEvent_Open_Window     1                /* Open Window or modeless dialog */
  49. #define UserEvent_Close_Window     2                /* Close Window or modeless dialog */
  50. #define UserEvent_Activate_Window     3            /* Activate Window or modeless dialog */
  51. #define UserEvent_Deactivate_Window     4            /* Deactivate Window or modeless dialog */
  52. /* IDs 0 to 999 reserved for Marksman™, all others available for special use */
  53.  
  54. /* Menu list resource IDs */
  55. #define Res_Menu_Apple     256                        /* Menu resource ID */
  56. #define MItem_About     1
  57.  
  58. #define Res_Menu_File     257                        /* Menu resource ID */
  59. #define MItem_Quit2     1
  60.  
  61. #define Res_Menu_Commands     258                    /* Menu resource ID */
  62. #define MItem_Enter_Coordinat     1
  63. #define MItem_Display     2
  64.  
  65.  
  66. /* Window resource IDs, also controls grouped with the appropiate window */
  67.  
  68. #define Res_MD_About_ARTAbrot     258                /* Modeless Dialog */
  69. #define Res_Dlg_OK2     1                            /* ...Button */
  70. #define Res_Dlg_Static_Text5     530                /* ...Static text */
  71. #define Res_Dlg_Picture     2                    /* ...Picture button */
  72.  
  73. #define Res_MD_Enter_Coordinat     257                /* Modeless Dialog */
  74. #define Res_Dlg_OK     1                            /* ...Button */
  75. #define Res_Dlg_Cancel     2                        /* ...Button */
  76. #define Res_Dlg_Static_Text4     521                /* ...Static text */
  77. #define Res_Dlg_Static_Text3     520                /* ...Static text */
  78. #define Res_Dlg_Static_Text2     518                /* ...Static text */
  79. #define Res_Dlg_Static_Text     517                /* ...Static text */
  80. #define Res_Dlg_Edit_Text4     3                    /* ...Edit text - iterations */
  81. #define Res_Dlg_Edit_Text3     4                    /* ...Edit text - width */
  82. #define Res_Dlg_Edit_Text2     5                    /* ...Edit text - Y coord. */
  83. #define Res_Dlg_Edit_Text     6                    /* ...Edit text - X coord. */
  84.  
  85. #define Res_W_ARTAbrot     256                        /* Window */
  86.  
  87. /* Picture resource IDs */
  88. #define Pict_Picture     30001
  89.  
  90. /* Sound resource IDs */
  91. #define Snd_Bart__Cooool     256
  92.  
  93.  
  94. /* ======================================================= */
  95.  
  96.  
  97. typedef struct UserEventRec{                        /* User Event Record definition */
  98.     short    ID;                                /* ID for the type of user event */
  99.     short    ID2;                                /* Optionally used, 2nd ID, sometimes used */
  100.     long    Data1;                                /* Optionally used, Extra data */
  101.     long    Data2;                                /* Optionally used, Extra data */
  102.     Handle    theHandle;                        /* Optionally used, Handle */
  103.     struct UserEventRec    **Next;                /* Handle of next event in the list */
  104. }UserEventRec,*UserEventPRec,**UserEventHRec;
  105.  
  106. extern Boolean    Doing_MovableModal;                /* For Movable Modal dialogs */
  107. extern UserEventHRec    UserEventList;                /* User Event record list start */
  108. extern EventRecord    myEvent;                        /* Event record for all events */
  109. extern Boolean    WNE;                                /* WaitNextEvent trap is available */
  110. extern short    SleepValue;                        /* Sleep value for Wait on events */
  111. extern Boolean    doneFlag;                        /* Exit program flag */
  112. extern TEHandle    theInput;                        /* Used in text edit selections */
  113. extern Rect    tempRect;                            /* Temporary rect, not for long term use */
  114. extern Str255    sTemp;                            /* Temporary string, not for long term use */
  115. extern Boolean        HasColorQD;                    /* Flag for Color QuickDraw being available */
  116. extern Boolean        HasFPU;                        /* Flag for Floating Point Math Chip being available */
  117. extern Boolean        HoldOffUserEvents;            /* Flag for holding off UserEvents */
  118. extern Boolean        InTheForeground;                /* Flag for running in MultiFinder foreground */
  119. extern short        tempChar;                        /* Temporary use character */
  120. extern long        LTemp;                            /* Temporary use long variable */
  121. extern RGBColor        Black_ForeColor,White_BackColor;/* Standard colors */
  122.  
  123. extern SFTypeList    typeList;                        /* For use in opening files */
  124. extern OSErr        ErrorCode;                        /* For use in reading and writing files */
  125. extern SFReply    Reply;                            /* For use in getting file names */
  126. extern StandardFileReply    theStandardFileReply;    /* For use in getting file names */
  127. extern short    inputRefNum;                        /* For the input file */
  128. extern short    outputRefNum;                        /* For the output file */
  129. extern Str255 inputFileName;                        /* For the input file */
  130. extern Str255 outputFileName;                        /* For the output file */
  131.  
  132. extern RgnHandle    cursorRgn;                        /* Cursor region for WaitNextEvent */
  133. extern Boolean        HasAppleEvents;                /* Whether AppleEvents are available */
  134. extern Boolean        HasAliasMgr;                    /* Whether AliasMgr is available */
  135. extern Boolean        HasEditionMgr;                /* Whether EditionMgr is available */
  136. extern short        ReplyMode;                        /* Reply mode for AppleEvents */
  137. extern Boolean        HasNewStdFile;                /* Whether HasNewStdFile is available */
  138. extern Boolean        HasPPCToolbox;                /* Whether PPCToolbox is available */
  139. extern Boolean        Has32BitQuickDraw;            /* Whether 32Bit QuickDraw is available */
  140. extern Boolean        HasGestalt;                    /* Whether Gestalt is available */
  141.  
  142. extern THPrint    hPrint;                            /* Printer record */
  143. extern Boolean    PrinterIsOpen;                    /* Whether printer is open or not */
  144. extern short    PageCount;                            /* For adding in page number */
  145. extern short    LineCount;                            /* For printing */
  146. extern short    PrinterVRes,PrinterHRes;            /* Printer resolution */
  147. extern short    MaxPrintCharacters;                /* Max characters on one line */
  148. extern short    MaxLines;                            /* Maximum lines in one page */
  149. extern TPPrPort        pPrPort;                    /* Printer port */
  150. extern TPrStatus        prStatus;                    /* Printing status */
  151. extern short    CopyCount;                            /* Number of copies to do */
  152.  
  153. extern MenuHandle    Menu_Apple;                    /* Menu handle */
  154. extern MenuHandle    Menu_File;                    /* Menu handle */
  155. extern MenuHandle    Menu_Commands;                /* Menu handle */
  156.  
  157. /* Window variables for the window titled  "ARTAbrot" */
  158. extern WindowPtr    WPtr_ARTAbrot;                    /* Window pointer */
  159.  
  160. /* Variables for the modeless dialog titled  "About ARTAbrot" */
  161. extern WindowPtr    WPtr_About_ARTAbrot;            /* Modeless Dialog window pointer */
  162.  
  163. /* Variables for the alert titled  "Alert" */
  164.  
  165. /* Variables for the modeless dialog titled  "Enter Coordinates" */
  166. extern WindowPtr    WPtr_Enter_Coordinat;            /* Modeless Dialog window pointer */
  167. extern Rect    DTE_Rect_Edit_Text4;                /* ...Edit text - iterations */
  168. extern Rect    DTE_Rect_Edit_Text3;                /* ...Edit text - width */
  169. extern Rect    DTE_Rect_Edit_Text2;                /* ...Edit text - Y coord. */
  170. extern Rect    DTE_Rect_Edit_Text;                    /* ...Edit text - X coord. */
  171.  
  172.  
  173. /* Mandelbrot coordinates. */
  174. extern float fxcenter, fycenter, fwidth; /* X center, Y center, and width of fractal. */
  175. extern int fiters;                /* Maximum number of iterations. */
  176. extern int new_coordinates;
  177.  
  178.  
  179. /* Prototypes */
  180.  
  181. /* Handle an activate of the window */
  182. void DoActivate(void);
  183.  
  184. /* See if WaitNextEvent is available */
  185. Boolean IsWNEIsImplemented(void);
  186.  
  187. /* Check for user events */
  188. void Handle_User_Event(void);
  189.  
  190. /* Handle a hit in the window */
  191. void DoInContent(WindowPtr whichWindow,EventRecord *myEvent);
  192.  
  193. /* ======================================================= */
  194.  
  195. /* Copy Pascal strings */
  196. void PStrCopy(Str255 *SourceString, Str255 *DestString);
  197.  
  198. /* Concat Pascal strings */
  199. void PStrCat(Str255 *SourceString, Str255 *DestString);
  200.  
  201. /* Compare Pascal strings for exact match, case sensitive */
  202. Boolean PStrCmp(StringPtr Source1String,StringPtr Source2String);
  203.  
  204. Boolean CheckTrapAvailable (short trapNumber, short tType);/* See if a trap is available */
  205.  
  206. void GetUserEvent(UserEventPRec TheUserEvent);        /* See if any user events are available */
  207.  
  208. void Add_UserEvent(short ID, short ID2, long  Data1, long Data2, Handle  theHandle);/* Add a user event */
  209.  
  210. void Play_The_Sound(short ResID);                    /* Play my sound */
  211.  
  212. /* This is a routine used to get a string from a TE area, limited to 250 characters */
  213. void Get_TE_String(TEHandle theTEArea, Str255 *theString);/* Get the TE String */
  214.  
  215. /* This is a routine used to create a TE area */
  216. void Make_TE_Area(TEHandle *theTEArea, Rect *Position, short theFontSize, short theFont, short DefaultStringID);/* Make the TE area */
  217.  
  218. void SetupTheItem (DialogPtr theDialog, short ItemID, Boolean SizeIt, Boolean ShowIt, Boolean EnableIt,/* Setup a dialog or alert item */
  219. Boolean SetTheMax,Rect * thePosition , long ExtraData , short StringID );/* Setup a dialog or alert item */
  220.  
  221. void CenterOnColorScreen ( WindowPtr theWindow );    /* Center a window onto the deepest color screen */
  222.  
  223. void GetDeepestColorScreenRect (Rect *DeepRect);    /* Get the deepest color screen rect */
  224.  
  225.